package edu.ccut.saturn.component.utils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;

public class ExceptionUtils {
	/**
	 * 输出日志信息到字符串
	 * @param e
	 * @return
	 */
	public static String getExMessage(Exception e) {
		String result = null;
		PrintWriter writer = null;
		try {
			Writer w = new StringWriter();
			writer = new PrintWriter(w);
			e.printStackTrace(writer);
			writer.flush();
			
			result = w.toString();
		} catch (Exception e1) {
			e1.printStackTrace();
		}finally{
			writer.close();
		}
		return result;
	}
}
